from config import ChromaConfig 
from data_loader import DataLoader
from chroma_manager import ChromaManager
import logging

def init_chromadb():
    """Initialize metadata into vector database"""
    try:
        # Configure logging
        logging.basicConfig(level=logging.INFO)
        logger = logging.getLogger(__name__)
        
        logger.info("Starting metadata initialization...")
        
        # Initialize config
        config = ChromaConfig(
            host="localhost",
            ollama_base_url="http://localhost:11434",
            embedding_model="viosay/conan-embedding-v1"
        )
        
        # Load data
        logger.info("Loading data from CSV files...")
        loader = DataLoader()
        indicators_df = loader.load_indicators()
        dimensions_df = loader.load_dimensions()
        
        # Store in ChromaDB
        logger.info("Storing data in ChromaDB...")
        chroma = ChromaManager(config)
        chroma.store_indicators(indicators_df)
        chroma.store_dimensions(dimensions_df)
        
        logger.info("Metadata initialization completed successfully")
        
    except Exception as e:
        logger.error(f"Error during initialization: {str(e)}")
        raise

if __name__ == "__main__":
    init_chromadb()